package it.carlom.stickyheader;

import it.carlom.stikkyheader.core.StikkyHeaderBuilder;
import it.carlom.stikkyheader.core.utils.PxUtil;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;
import ohos.agp.components.ScrollView;
import ohos.app.Context;
import org.junit.Assert;
import org.junit.Test;

/**
 * ohos单元测试
 */
public class ExampleOhosTest {

    private final Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    /**
     * fp2px
     */
    @Test
    public void PixelUtil_fp2px() {
        PxUtil.initContext(context);
        float px = PxUtil.fp2px(10);
        Assert.assertEquals(30.5, px, 0.0);
    }

    /**
     * vp2px
     */
    @Test
    public void PixelUtil_vp2px() {
        PxUtil.initContext(context);
        float px = PxUtil.vp2px(10);
        Assert.assertEquals(30.5, px, 0.0);
    }

    /**
     * tickTo
     */
    @Test(expected = NullPointerException.class)
    public void testStickTo() {
        StikkyHeaderBuilder.stickTo((ListContainer) null);
    }

    /**
     * tickTo
     */
    @Test(expected = NullPointerException.class)
    public void testStickTo1() {
        StikkyHeaderBuilder.stickTo((ScrollView) null);
    }

    /**
     * SetHeader
     */
    @Test
    public void testSetHeader() {
        ScrollView scrollView = new ScrollView(context);
        Component header = new Component(context);
        StikkyHeaderBuilder.stickTo(scrollView).setHeader(header).build();
    }


}